#ifndef _FILTER_DATA_H_H
#define _FILTER_DATA_H_H

#include <vector>
#include <Eigen/Dense>

// C++ FiltFilt
#include "sos2tf_kfr.h"
#include "FiltFilt/FiltFilt.h"
using namespace kb::math;

// kfr
#include <kfr/base.hpp>
#include <kfr/dsp.hpp>
#include <kfr/io.hpp>
using namespace kfr;

void _filter_data(double *vec, const int M, const std::vector<univector<fbase>>bqs, const std::string str = "low")
{
  if (str == "low") {
    #ifndef _USING_SOS 
    {
      std::vector<double> out;
      std::vector<double> stdvec(vec, vec+M);
      stdvec = filtfilt_lowpass.ZeroPhaseFiltering(stdvec);
      //mat17.col(j) = Eigen::Map<Eigen::VectorXd>(out.data(), out.size());
    }
    #else 
    {
      //constexpr size_t maxorder = order;
      univector<fbase> vec = make_univector(vec, M);
      vec = biquad<32>(bqs, vec);
      // out = biquad<8>(bqs.data(), bqs.size(), line1);
      //mat17.col(j) = Eigen::Map<Eigen::VectorXd>(out.data(), out.size());
    }
  } else {
    #ifndef _USING_SOS 
    {
      std::vector<double> out;
      std::vector<double> stdvec(vec, vec+M);
      stdvec = filtfilt_bandpass.ZeroPhaseFiltering(stdvec);
      //mat17.col(j) = Eigen::Map<Eigen::VectorXd>(out.data(), out.size());
    }
    #else 
    {
      //constexpr size_t maxorder = order;
      univector<fbase> vec = make_univector(vec, M);
      vec = biquad<32>(bqs, vec);
      // out = biquad<8>(bqs.data(), bqs.size(), line1);
      //mat17.col(j) = Eigen::Map<Eigen::VectorXd>(out.data(), out.size());
    }
    #endif    
  }

}

#endif
